var express = require('express');
var fs      = require('fs');
var path    = require('path');
var room    = require('./room');

var router  = express.Router();

var server = require('./server');

router.get('/', function(req, res, next) {
  if (req.isAuthenticated()) {
  	res.redirect('/admin');
  }

  res.redirect('/login');
});

router.get('/login', function(req, res, next) {
	res.render('login')
})

router.post('/login', function(req, res, next) {
  passport.authenticate('local', {
      successRedirect: '/admin',
      failureRedirect: '/'
  })
})

router.use('/room', room);

router.use('/server', server);

module.exports = router;
